import React, { FC, useEffect, useState } from 'react'
import { Space, Typography } from 'antd'
import { Link } from 'react-router-dom'
import { FormOutlined } from '@ant-design/icons'
const { Title } = Typography
import useGetUserInfo from '../hooks/useGetUserInfo'
import styles from './Logo.module.scss'
import { HOME_PATHNAME, MANAGE_INDEX_PATHNAME } from '../router'

const Logo: FC = () => {
    const { username } = useGetUserInfo()
    const [pathname, setPathname] = useState(HOME_PATHNAME)
    useEffect(() => {
        if (username) {
            setPathname(MANAGE_INDEX_PATHNAME)
        }
    }, [username])
    return (
        <div className={styles.container}>
            <Link to={pathname}>
                <Space>
                    <Title>
                        <FormOutlined />
                    </Title>
                    <Title>小滕问卷</Title>
                </Space>
            </Link>
        </div>
    )
}

export default Logo
